<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text">
    <button>发送短信</button>
    <script>
        var time = 30;
        var btn = document.querySelector('button');
        var inp = document.querySelector('input');
        btn.addEventListener('click', function () {
            btn.disabled = true;
            btn.innerHTML = time;
            var timer = setInterval(function () {
                btn.innerHTML = --time;
                if(time==0){
                clearInterval(timer);
                time = 30;
                btn.disabled = false;
                btn.innerHTML = '发送短信';
            }
            }, 1000)
            
        })


    </script>
</body>

</html>